package com.company.quick56.web.bean;

import java.io.Serializable;

import org.operamasks.faces.annotation.Action;
import org.operamasks.faces.annotation.Bind;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import org.operamasks.faces.component.layout.impl.UITabLayout;
import org.operamasks.faces.component.tree.impl.UITree;
import org.operamasks.faces.component.tree.impl.UITreeNode;

/**
 * 
 * This managed bean is generated automatically
 */
@ManagedBean(name = "indexBean", scope = ManagedBeanScope.SESSION)
public class IndexBean implements Serializable {

	@Bind
	private UITabLayout centerTab;

	@Bind
	private UITree bizHandle;

	@Bind
	private UITree baseData;

	@Action
	public void bizHandle_onclick() {
		showPanel(bizHandle);
	}

	@Action
	public void baseData_onclick() {
		showPanel(baseData);
	}

	private void showPanel(UITree tree) {
		UITreeNode node = tree.getEventNode();
		if (node == null || !Boolean.TRUE.equals(node.getLeaf())) {
			return;
		}

		// 选中树结点时动态增加相应tab
		centerTab.addTab(node.getText(), node.getUserData().toString());
	}

}
